#include "aicoder_enhancements.h"
#include "unified_ai_client.h"
#include <fstream>
#include <sstream>

AICoderEnhancements::AICoderEnhancements() : m_aiClient(new UnifiedAIClient()) {}

AICoderEnhancements::~AICoderEnhancements() {
    delete m_aiClient;
}

std::string AICoderEnhancements::GetAIEnhancedMakefile(const std::string& cbpContent, const std::string& modelType) {
    // 设置模型
    if (modelType == "DSAI") {
        m_aiClient->SetModel(AI_DEEPSEEK, "DS-V3.2exp0922");
    } else if (modelType == "UEAI") {
        m_aiClient->SetModel(AI_UE_CODEEXPERT, "UE-CodeExpert");
    } else if (modelType == "OPAI") {
        m_aiClient->SetModel(AI_OPENAI, "GPT-4");
    }
    
    return m_aiClient->ChatCompletion("Analyze CBP: " + cbpContent.substr(0, 100));
}

std::vector<std::string> AICoderEnhancements::ParseSourceFiles(const std::string& cbpFile) {
    return {"main.cpp", "utils.cpp"};
}

std::string AICoderEnhancements::ReadFileContent(const std::string& filePath) {
    std::ifstream file(filePath);
    std::stringstream buffer;
    buffer << file.rdbuf();
    return buffer.str();
}

bool AICoderEnhancements::IsAIEnabled() const {
    return true;
}

std::string AICoderEnhancements::GetModelStatus() const {
    return m_aiClient->GetModelStatus();
}
